import thirdService from 'service/thirdService.js'
import userService from 'service/userService.js'
import configService from 'service/configService.js'
export default {
    getChineseRealation: function(value) {
        if (!value) {
            return ''
        }
        let relationData = {
            'FATHER': '爸爸',
            'MOTHER': '妈妈',
            'GRANDMOTHER': '奶奶',
            'GRANDFATHER': '爷爷',
            'OTHER_FAMILIES': '其他家人'
        }
        return relationData[value]
    },
    getAllTaskStatus() {
        let statusData = [{
            "key": "OPEN",
            "name": "未处理"
        }, {
            "key": "PENDING",
            "name": "处理中"
        }, {
            "key": "CLOSED",
            "name": "已完结"
        }]
        return statusData;
    },
    getChineseTaskStatus(value) {
        if (!value) {
            return ''
        }
        let statusData = this.getAllTaskStatus()
        let statusItem = statusData.find((item, index) => {
            return item.key == value
        })

        return statusItem.name
    },
    playAudio(url, id) {
        console.log(url)
            // Check for audio element support.
        if (window.HTMLAudioElement) {
            try {
                var oAudio = document.querySelector('#' + id);
                //Skip loading if current file hasn't changed.
                oAudio.src = url;
                console.log(oAudio.paused)
                    // Tests the paused attribute and set state. 
                if (oAudio.paused) {
                    oAudio.play();
                } else {
                    oAudio.pause();
                }
            } catch (e) {
                // Fail silently but show in F12 developer tools console
                if (window.console && console.error("Error:" + e));
            }
        }
    },
    isNull(obj) {
        if (obj != null) {
            return obj;
        }
        return;
    },
    getLoginMessage() {
        let messageHtml = '<div class="mask"><div>登陆超时，请重新<a href="/login">登陆</a></div></div>'
        console.log(messageHtml)
        document.body.appendChild(messageHtml)
    }
}